﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.Refer;
using PowerCreator.LMS.Refer.Entity;

public partial class sysadmin_ReferManager_AddRefer : PowerCreator.LMS.Web.Base.BasePage
{
    Refer objRefer = new Refer();

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (IsLicensed(PowerCreator.LMS.Action.Core.ActionInfo.AddJob))
        //{
        //    Script.RedirectURL(GetRefUrl());
        //}
        if (!IsPostBack)
        {
            InitPage();
        }
    }
    protected override void InitPage()
    {
        //lbl_InfoTitle.Text = GetLanageValueByKey("lbl_AddJob_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_JobName.Text = GetLanageValueByKey("lbl_AddJob_JobName", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_JobDescription.Text = GetLanageValueByKey("lbl_AddJob_JobDescription", PowerCreator.LMS.Language.LanagetItemType.Page);

        //btnSave.Text = GetLanageValueByKey("btn_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        //btnReset.Text = GetLanageValueByKey("btn_Reset", PowerCreator.LMS.Language.LanagetItemType.Page);
        //base.InitPage();

        lbl_InfoTitle_AddRefer.Text = GetLanageValueByKey("lab_AddRefer_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_ReferInfo.Text = GetLanageValueByKey("lab_AddRefer_QuestionInfo", PowerCreator.LMS.Language.LanagetItemType.Page);
        lab_ReferTitle.Text = GetLanageValueByKey("lab_AddRefer_ReferTitle", PowerCreator.LMS.Language.LanagetItemType.WebPage);
        lab_ReferContent.Text = GetLanageValueByKey("lab_AddRefer_ReferContent", PowerCreator.LMS.Language.LanagetItemType.WebPage);
        lab_ReferName.Text = GetLanageValueByKey("lab_AddRefer_ReferName", PowerCreator.LMS.Language.LanagetItemType.WebPage);
        lab_ReferEmail.Text = GetLanageValueByKey("lab_AddRefer_ReferEmail", PowerCreator.LMS.Language.LanagetItemType.WebPage);
        lab_ReferTelephone.Text = GetLanageValueByKey("lab_AddRefer_ReferTelephone", PowerCreator.LMS.Language.LanagetItemType.WebPage);

        btnSave.Text = GetLanageValueByKey("btn_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        btnReset.Text = GetLanageValueByKey("btn_Reset", PowerCreator.LMS.Language.LanagetItemType.Page);
        base.InitPage();
    }
    private bool CheckPageData()
    {
        string search = string.Format("ReferTitle = '{0}'", txt_ReferTitle.Text);
        if (objRefer.Count(search) != 0)
        {

            //lbl_msg_Error.Text = GetLanageValueByKey("lbl_msg_addjob_aspx_count", PowerCreator.LMS.Language.LanagetItemType.MSG);

            lbl_msg_Error.Text = "<br />" + GetLanageValueByKey("msg_AddRefer_Msg1", PowerCreator.LMS.Language.LanagetItemType.Page);
            return false;
        }
        return true;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!CheckPageData()) return;
        VOTRefer vo = new VOTRefer();
        vo.ReferTitle = txt_ReferTitle.Text.Trim();
        vo.ReferContent = txt_ReferContent.Text.Trim();
        vo.ReferName = txt_ReferName.Text.Trim();
        vo.ReferEmail = txt_ReferEmail.Text.Trim();
        vo.ReferTelephone = txt_ReferTelephone.Text.Trim();
        vo.ReferTime = DateTime.Now;


        if (objRefer.AddRefer(vo))
        {
            string url = "ManagerRefer.aspx";
            Script.RedirectURL(url);
        }
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        string url = "ManagerRefer.aspx";
        Script.RedirectURL(url);
    }
}
